module MuIDE
class ObjectAttributeViewer
  attr_accessor :list,:panel
  def initialize(pane)
    f=Wx::Panel::new(pane)
    @panel=f
    list = ListCtrl::new(f,Wx::LC_REPORT|Wx::LC_VIRTUAL|Wx::LC_VRULES|Wx::LC_HRULES,f)
    list.array = ["","",""]
    a=list
#     f.list = list
    attr0 = Wx::ListItemAttr.new()
    attr0.set_background_colour(Wx::Colour.new("#CCCEEE"))
    attr1 = Wx::ListItemAttr.new()
    attr1.set_background_colour(Wx::Colour.new("GREY"))
    attr2 = Wx::ListItemAttr.new()
    attr2.set_background_colour(Wx::Colour.new("#CECECE"))
    attr3 = Wx::ListItemAttr.new()
    attr3.set_background_colour(Wx::Colour.new("#CEEEEE"))
    attr4 = Wx::ListItemAttr.new()
    attr4.set_background_colour(Wx::Colour.new("#CFFFFF"))
    list.instance_variable_set("@attr0",attr0)
    list.instance_variable_set("@attr1",attr1)
    list.instance_variable_set("@attr2",attr2)
    list.instance_variable_set("@attr3",attr3)
    list.instance_variable_set("@attr4",attr4)
    a.insert_column(0,"Dbref")
    a.insert_column(1,"Name")
    a.insert_column(2,"Location")
    a.insert_column(3,"Link_To")
    a.insert_column(4,"Type")
    a.insert_column(5,"Flags")
    a.set_column_width(0,55)
    a.set_column_width(1,60)
    a.set_column_width(2,60)
    a.set_column_width(3,60)
    a.set_column_width(5,160)
    a.set_item_count(100)
    f.evt_list_item_selected(a.get_id) {|event| a.on_item_selected(event);on_sel(event,a,f)}
    f.evt_list_item_activated(a.get_id) {|event| a.on_item_activated(event);on_activate(event,a,f);}
#     obj=f.object
    @list = a
    p WxRide
#     f.m_panel91.set_size Wx::Size::new(800,800)
#     f.m_panel91.sizer.add list,Wx::GROW,Wx::GROW,Wx::EXPAND
#     f.m_textctrl102.hide
#     f.m_treectrl2.hide
#     @sty = WxRide::EditorPage::new(f.m_panel71)
#     @sty.evt_key_up {|e| $client.handle_key e,@sty}
#     @sty.set_stc_focus 1
#     f.m_panel71.sizer.add @sty,0,Wx::GROW,Wx::EXPAND
#     f.show
     @panel.set_sizer Wx::BoxSizer::new Wx::VERTICAL
     @panel.sizer.add Wx::StaticText::new(@panel,-1,"Realize an object from the server to display it here")
     @panel.sizer.add @list,Wx::GROW|Wx::ALL,Wx::EXPAND
  end
  def on_activate(*args)

  end
  def on_sel event,a,f
    sel = event.get_index()
    begin
      path = a.get_node_path(sel)
      node = a.get_node(path)
      if a.root_nodes.index(node)
        object = $objects[node.get_index[0]].clone
        object.instance_variable_set("@root_node",nil)
        object.instance_variable_set("@at_node",nil)
        object.instance_variable_set("@and_node",nil)
        object.instance_variable_set("@lock_node",nil)
        object.instance_variable_set("@atty_node",nil)
        object.connection = nil
#         f.m_textctrl2.value = object.to_yaml
      elsif node.parent == $objects[node.get_index[0]].and_node 
        object = $objects[node.get_index[0]]
#         f.m_textctrl2.value = object.attributes[:and][node.iter[1].to_sym][:data].to_yaml
#         f.m_textctrl8.value = object.dbref+"/"+node.iter[1]
      elsif node.parent == $objects[node.get_index[0]].at_node
        object = $objects[node.get_index[0]]
#         f.m_textctrl2.value = object.attributes[:at][node.iter[1].to_sym][:data].to_yaml 
      end
    rescue
    end
  end
end
end